// 封装房源管理相关接口
import request from '@/utils/request'

// 房源列表
// 获取房源列表信息
export const getPropertyListService = ({ id, pageSize, page }) => {
  return request({
    url: `/api/property/list/${id}`,
    method: 'GET',
    params: {
      pageSize: pageSize,
      page: page
    }
  })
}

// 房源列表搜索功能实现
export const searchPropertyService = (data) => {
  return request({
    url: '/api/property/search',
    method: 'GET',
    params: {
      data
    }
  })
}

// 获取房源详情信息
export const getPropertyDetailService = (id) => {
  return request({
    url: `/api/property/detail/${id}`,
    method: 'GET'
  })
}

// 创建房源
export const publishPropertyService = (data) => {
  return request({
    url: '/api/property/publish',
    method: 'POST',
    data
  })
}

// 删除房源
export const deletePropertyService = (id) => {
  return request({
    url: `/api/property/${id}`,
    method: 'DELETE'
  })
}

// 热门房源
// 获取热门房源信息
export const getHotPropertyService = ({ pageSize, page }) => {
  return request({
    url: '/api/hot',
    method: 'GET',
    params: {
      pageSize,
      page
    }
  })
}

// 添加热门房源
export const addHotPropertyService = (id) => {
  return request({
    url: `/api/property/hot/add/${id}`,
    method: 'PATCH'
  })
}

// 删除热门房源
export const deleteHotPropertyService = (id) => {
  return request({
    url: `/api/property/hot/del/${id}`,
    method: 'PATCH'
  })
}

// 热门房源搜索功能实现
export const searchHotPropertyService = (data) => {
  return request({
    url: '/api/hot/search',
    method: 'GET',
    params: {
      data
    }
  })
}
